<?=view('header.html')?>

<body>


    <form class="layui-form mokui-form" lay-filter="form-ashopadd" id="form-ashopadd" style="padding: 20px 0 0 0;">
        
        <div class="layui-form-item">
            <label class="layui-form-label">选择角色分组</label>
            <div class="layui-input-inline">
                <select name="data[roleid]" lay-filter="required" id="ams_role" class="form-control ">
                    <option value="">--请选择角色组--</option>
                    <?php if($role):?>
                    <?php foreach($role as $r):?>
                    <option value="<?=$r['id']?>" <?php if((isset($data['roleid']) && $data['roleid']==$r['id']) || $r['id']==$roleid){echo 'selected';}?>><?=$r['name']?></option>
                    <?php endforeach;?>
                    <?php endif;?>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">登录账号</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" name="data[username]" id="ams_username" value="<?=isset($data['username']) ? $data['username'] : ''?>" size="20" />
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">登录密码</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" name="data[password]" placeholder="不修改就不填" id="ams_password" value="" />
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">姓名/称呼</label>
            <div class="layui-input-inline">
                <input type="text" value="<?=isset($data['name']) ? $data['name'] : ''?>" name="data[name]" placeholder="姓名或者称呼" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" name="data[phone]" id="ams_phone" value="<?=isset($data['phone']) ? $data['phone'] : ''?>" />
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">邮箱</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" name="data[email]" id="ams_email" value="<?=isset($data['email']) ? $data['email'] : ''?>" />
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-input-block">
                <input type="button" class="layui-btn" lay-submit lay-filter="submitSave" value="提交保存">
            </div>
        </div>
    </form>

    <?=view('footer.html')?>

    <script type="text/javascript">
        layui.use(['layer', 'form', 'jquery', 'table'], function () {
            var layer = layui.layer,
                $ = layui.jquery,
                form = layui.form
            table = layui.table;

            var url = window.location.href;
            

            form.on('submit(submitSave)', function (data) {
                $.post(url, data.field, function (res) {
                    if (res.code == 0) {
                        layer.msg(res.msg, { time: 1500, icon: 1 }, function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.location.reload();
                            parent.layer.close(index);
                        });
                    } else {
                        layer.msg(res.msg, { time: 2000, icon: 5 });
                    }
                }, 'json')
            });

        });
    </script>

</body>

</html>
